/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "RgnPolygon.h"
#include "MList.h"

enum RgnWindowRecType
{
	__rwrtUnknown,
	__rwrtNone,
	__rwrtPolygon,
	__rwrtClient
};

class RgnWindow
{
private:
	MList polygons;
	void CleanUp(void);

	bool IsRegionPolygon(RgnPolygon*);
	HRGN CreateNewRegion(RgnPolygon*, int, int);

	CStdioFile theFile;

	RgnWindowRecType currentRecType;
	RgnPolygon* currentPoly;
	RgnPolygon* CreateNewPolygon(RgnPloygonType);
	bool AddCurrentPolygon(void);
	bool ProcessLine(char*);
	bool ProcessRecTypeLine(char*);

public:
	RgnWindow(void);
	~RgnWindow(void);

	void Initialize(void);

	bool SetRegion(HWND, int, int);
	bool GetClientRectangle(RECT*, int, int);

	bool LoadFromFile(CString);

	bool SetDefaultClientRegion(int);
};
